<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ count }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: type === 'one' }"
          @click="changeType('one')"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: type === 'two' }"
          @click="changeType('two')"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: type === 'three' }"
          @click="changeType('three')"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" v-show="showClear" @click="clearDoneAsync">
      清除已完成
    </button>
  </footer>
</template>

<script>
import { mapActions, mapGetters, mapMutations, mapState } from "vuex";

export default {
  computed: {
    ...mapState("todos", ["type"]),
    ...mapGetters("todos", ["count", "showClear"]),
  },

  methods: {
    ...mapActions("todos", ["clearDoneAsync"]),
    ...mapMutations("todos", ["changeType"]),
  },
};
</script>
